<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">

        <h:panelGroup >
            <h:form  >
                <p:growl />
                <p:focus id="selectFocus" context="gpSelect" />
                <p:focus id="detailFocus" context="gpDetail" />



                <p:panel header="Manage Doctor" >
                    <h:panelGrid id ="gpVeda" columns="2" styleClass="alignTop">

                        <h:panelGrid id="gpSelect" columns="1"  >
                            <p:panel >
                                <h:panelGrid id="gpSelectText" >

                                    <p:selectOneMenu value="#{consultantController.speciality}" >
                                        <f:selectItem itemLabel="Please select a speciality"/>
                                        <f:selectItems value="#{doctorSpecialityController.items}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                        <f:ajax execute="@this" render="lstSelect" event="change" />
                                    </p:selectOneMenu>
                                    <p:inputText autocomplete="off" value="#{consultantController.selectText}" >
                                        <f:ajax execute="@this" render="lstSelect" event="keyup" />
                                    </p:inputText>

                                    <h:selectOneListbox  id="lstSelect"   size="10" value="#{consultantController.current}" style="min-width: 223px;">
                                        <f:selectItems  value="#{consultantController.selectedItems}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.person.nameWithTitle}"  ></f:selectItems>
                                        <f:ajax render="gpDetail" execute="lstSelect" />                                        
                                    </h:selectOneListbox>

                                </h:panelGrid>
                                <h:panelGrid id="gpSelectButtons" columns="3"  >
                                    <p:commandButton id="btnAdd" value="Add"  
                                                     action="#{consultantController.prepareAdd()}" styleClass="buttons" ajax="false"/>                                   
                                    <p:commandButton ajax="false" id="btnDelete" 
                                                     onclick="if (!confirm('Are you sure you want to delete this record?'))
                                                                 return false;" action="#{consultantController.delete()}"  value="Delete">
                                    </p:commandButton>
                                </h:panelGrid>

                            </p:panel>
                            <p:commandLink value="Consultant List" action="admin_doctor_consultant_1" ajax="false" />
                        </h:panelGrid  >

                        <p:panel>
                            <h:panelGrid id="gpDetail" columns="1">


                                <p:tabView id="gpDetailText" >
                                    <p:tab title="Basic Details" >
                                        <h:panelGrid columns="2">
                                            <h:outputText  value="Title" />
                                            <p:selectOneMenu  id="cmbTitle"  
                                                              value="#{consultantController.current.person.title}"  >
                                                <f:selectItem itemLabel="Select Title" />
                                                <f:selectItems value="#{enumController.titleDoctor}" var="i" 
                                                               itemLabel="#{i.label}" itemValue="#{i}"/>
                                            </p:selectOneMenu>
                                            <h:outputText  value="Name" />
                                            <p:inputText autocomplete="off" value="#{consultantController.current.person.name}"  />
                                            <h:outputText  value="Code" />
                                            <p:inputText autocomplete="off" value="#{consultantController.current.code}"  />
                                            <h:outputText  value="*Consultant Serial No" />
                                            <p:inputText autocomplete="off" value="#{consultantController.current.codeInterger}"  />
                                            <h:outputText  value="Phone" />
                                            <p:inputMask mask="999-9999999" value="#{consultantController.current.person.phone}"  />
                                            <h:outputText  value="Fax" />
                                            <p:inputText autocomplete="off"  value="#{consultantController.current.person.fax}"  />
                                            <h:outputText  value="Mobile" />
                                            <p:inputText autocomplete="off" value="#{consultantController.current.person.mobile}"  />
                                            <h:outputText  value="Address" />
                                            <p:inputText autocomplete="off" value="#{consultantController.current.person.address}"  />
                                            <h:outputText value="Speciality" />
                                            <p:selectOneMenu value="#{consultantController.current.speciality}" >
                                                <f:selectItem itemLabel="Please select a speciality"/>
                                                <f:selectItems value="#{doctorSpecialityController.items}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                            </p:selectOneMenu>
                                            <h:outputText value="Registration" />
                                            <p:inputText autocomplete="off" value="#{consultantController.current.registration}" />
                                            <h:outputText value="Qualification" />
                                            <p:inputText autocomplete="off"  value="#{consultantController.current.qualification}" />
                                            <h:outputText  value="Refering Charge" />
                                            <p:inputText autocomplete="off"  value="#{consultantController.current.charge}"  />



                                        </h:panelGrid>
                                    </p:tab>
                                    <p:tab title="Edit" >
                                        <h:panelGrid columns="2" >

                                            <h:outputText  value="ID" />
                                            <h:outputText  value="#{consultantController.current.id}" />

                                            <h:outputText  value="Creater" />
                                            <h:outputText  value="#{consultantController.current.creater.webUserPerson.nameWithTitle}" />
                                            <h:outputText  value="Created At" />
                                            <h:outputText  value="#{consultantController.current.createdAt}" >
                                                <f:convertDateTime pattern="dd MMMM yyyy hh:mm a" ></f:convertDateTime>
                                            </h:outputText>

                                        </h:panelGrid>
                                    </p:tab>
                                </p:tabView>



                                <h:panelGrid id="gpDetailButtons" columns="2">
                                    <p:commandButton id="btnSave" value="Save" ajax="false"
                                                     action="#{consultantController.saveSelected()}" styleClass="buttons"/>

                                    <p:defaultCommand target="btnSave"/>
                                </h:panelGrid>
                            </h:panelGrid>
                        </p:panel>
                    </h:panelGrid>
                </p:panel>
            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>
